package zee.com.customviewexample.activity

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.zee.dialog.BindViewAdapter
import com.zee.dialog.LoadingDialog
import com.zee.dialog.MyDialog
import com.zee.extendobject.postDelayed
import com.zee.extendobject.setVisible
import zee.com.customviewexample.R

class MyDialogMainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_dialog_main)
    }

    fun testMargin(paView: View?) {
        //显示顶部
        MyDialog.init(object : BindViewAdapter(R.layout.dialog_top) {
            override fun initViews(paView: View) {
                findViewByIdK(R.id.view_stub).setVisible()
            }
        }).show(supportFragmentManager)
    }

    fun showTop(paView: View?) {
        //显示顶部
        MyDialog.initTop(object : BindViewAdapter(R.layout.dialog_top) {
            override fun initViews(paView: View) {}
        }).setMarginTopOrBottom(30).show(supportFragmentManager)
    }

    fun showMid(paView: View?) {
        //显示中间
        MyDialog.init(object : BindViewAdapter(R.layout.dialog_mid) {
            override fun initViews(paView: View) {
                setText(R.id.id_mid_value_view, "设置上值")
            }
        }).setMarginLeftAndRight(20).show()
    }

    fun showBottom(paView: View?) {
        //显示底部
        MyDialog.initBottom(object : BindViewAdapter(R.layout.dialog_bottom) {
            override fun initViews(paView: View) {}
        }).show(supportFragmentManager)
    }

    fun showAnimal(paView: View?) {
        //Dialog动画
        MyDialog.init(object : BindViewAdapter(R.layout.dialog_animal) {
            override fun initViews(paView: View) {
                postDelayed(100) {

                }
            }
        }).setAnimStyle(R.style.myDialogStyle_animal).show()
    }

    fun showLoad(view: View?) {
        LoadingDialog.newLoadDialog().setLoadingTxt("开始加载").show(supportFragmentManager)
    }
}